python怎么画圆螺旋线

您所在的位置:网站首页 python turtle作品 python怎么画圆螺旋线

python怎么画圆螺旋线

#python怎么画圆螺旋线| 来源: 网络整理| 查看: 265

完整的代码如下:

import matplotlib.pyplot as plt

import numpy as np

fig = plt.figure(figsize=(8, 8))

plt.ylim([-1.5, 1.5])

plt.xlim([-1.5, 1.5])

plt.grid(True)

ax = plt.gca()

ax.spines['right'].set_color('none')

ax.spines['top'].set_color('none')

ax.xaxis.set_ticks_position('bottom')

ax.spines['bottom'].set_position(('data', 0))

ax.yaxis.set_ticks_position('left')

ax.spines['left'].set_position(('data', 0))

n = 3

theta = np.arange(0, 2 * np.pi, np.pi/100)

x0 = (n + 1) / n * np.cos(theta)

y0 = (n + 1) / n * np.sin(theta)

plt.plot(x0, y0, '--')

x = np.cos(theta) + 1 / n * np.cos(n*theta)

y = np.sin(theta) - 1 / n * np.sin(n*theta)

plt.plot(x, y )

plt.show()



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3